<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
%>
<input type="hidden" name="keyId" id="keyId" value="${keyId}" />
<fieldset>
  <ul class="list-group" id="ajax_query">
  <c:forEach items="${dutyArrayList}" varStatus="i" var="list" >
    <li id="${list.id}" class="list-group-item">
      <div class="checkbox" style="display:inline">
        <label>
            <span>
              <input type="checkbox" id="${list.id}" ${list.checked} name="ck_duty_info" />
              ${list.department.name}<c:choose><c:when test="${list.post}==null || ${empty list.post}"></c:when><c:otherwise>(${list.post.name})</c:otherwise></c:choose>
            </span>
        </label>
        <a title="删除" key="ajax_duty_actions_delete" class="btn btn-danger btn-xs pull-right"
           href="javascript:void(0);"><i class="fa fa-times"></i>删除</a>
      </div>
    </li>
  </c:forEach>
  </ul>
</fieldset>

<script>
  function fn_member_dutyView(){
    var keyId= $("div").data("keyId");
    var actionUrl = "<%=path%>/main/member/defaultDuty";
    var data={keyId:keyId, userId:$('#keyId').val()};
    __ajax_post(actionUrl, data, function(pdata) {
      __toastr_success(pdata.message);
      $("#member_table").jqGrid().setGridParam({datatype:'json'}).trigger("reloadGrid");
    });
  }

  $("input[name='ck_duty_info']").unbind("click").bind("click",function(){
    if($(this).prop("checked")){
      $("input[name='ck_duty_info']:checked").attr("checked",false);
      $(this).prop('checked',true);
    }
    $("div").data("keyId",$(this).attr("id"));
  });

  $("a[key=ajax_duty_actions_delete]").click(function(){
    var id=$(this).parent().parent();
    var actionUrl = "<%=path%>/main/member/deleteDuty";
    var data={keyId:id.attr("id") };
    __ajax_post(actionUrl, data, function(pdata) {
      __toastr_success(pdata.message);
      loadURL("<%=path%>/main/member/dutyView/"+$("input#keyId").val(), $('#ajax_query'));
      $("#member_table").jqGrid().setGridParam({datatype:'json'}).trigger("reloadGrid");
    });
  });

</script>